package Javacode_8;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class LotteryDemo {
    public static void main(String[] args) {

        Random random = new Random();

        Set<Integer> lotteryNumbers = new HashSet<>();

        while (lotteryNumbers.size() < 7) {
            int number = random.nextInt(36) + 1;
            lotteryNumbers.add(number);
        }
        System.out.println("36选7摇号结果为：");
        int count = 1;
        for (int num : lotteryNumbers) {
            System.out.print(num + (count++ % 7 == 0 ? "" : " "));
        }
    }
}

